//
//  ViewController.m
//  ZLLCrashReportDemo
//
//  Created by 张亮亮 on 2018/3/30.
//  Copyright © 2018年 张亮亮. All rights reserved.
//

#import "ViewController.h"
#import "ZLLSignalReport.h"
#import "ZLLMachReport.h"
#import "ZLLExceptionReport.h"
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    [self exceptionCrashTest];
    
    
    return;
    
}
#pragma mark - MachCrash
- (void)machCrashTest {
     NSLog(@"MachReport:%d", installMachHandler()) ;
    sleep(2);
    char* invalid = (char*)-1;
    *invalid = 1;
}
#pragma mark - signalCrash
//必须真机在不连接电脑的情况下
- (void)signalCrashTest {
    NSLog(@"SignalReport:%d", installSignalHandler()) ;
    sleep(2);
    
    NSString *str = [ZLLSignalReport currentCrashLogInfoAndClear];
    if (str.length) {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"程序出现问题啦" message:str delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil];
        [alertView show];
     
    }else{
        abort();
    }
}
#pragma mark - Exception
- (void)exceptionCrashTest{
    installExceptionHandler();
    //2.ios崩溃
    NSArray *array= @[@"tom",@"xxx",@"ooo"];
    [array objectAtIndex:5];
}


@end
